package enumliteralisunique;

import org.eclipse.emf.ecore.EObject;

import org.eclipse.viatra2.emf.incquery.validation.runtime.Constraint;
import org.eclipse.viatra2.emf.incquery.validation.runtime.ValidationUtil;
import org.eclipse.viatra2.emf.incquery.runtime.api.impl.BaseGeneratedMatcherFactory;
import enumliteralisunique.EnumLiteralIsUniqueMatch;
import enumliteralisunique.EnumLiteralIsUniqueMatcherFactory;
import enumliteralisunique.EnumLiteralIsUniqueMatcher;

public class EnumLiteralIsUniqueConstraint extends Constraint<EnumLiteralIsUniqueMatch> {

	private EnumLiteralIsUniqueMatcherFactory matcherFactory;

	public EnumLiteralIsUniqueConstraint() {
		matcherFactory = new EnumLiteralIsUniqueMatcherFactory();
	}

	@Override
	public String getMessage() {
		return "Literal $literal.id$ of the $enumeration$ enumeration matches with literal $literal2.id$ of this enumeration. Enumerations should have unique literals!";
	}

	@Override
	public EObject getLocationObject(EnumLiteralIsUniqueMatch signature) {
		Object location = signature.get("enumeration");
		if(location instanceof EObject){
			return (EObject) location;
		}
		return null;
	}
	
	@Override
	public int getSeverity() {
		return ValidationUtil.getSeverity("error");
	}
	
	@Override
	public BaseGeneratedMatcherFactory<EnumLiteralIsUniqueMatch, EnumLiteralIsUniqueMatcher> getMatcherFactory() {
		return matcherFactory;
	}
}
